public final class af
{

    private static af c = null;
    public cc a;
    public boolean b;

    public static af a()
    {
        if(c == null)
            c = new af();
        return c;
    }

    public af()
    {
        a = new cc();
        b = false;
    }

    public final void b()
    {
        ce.a("Updating cached BGWidgets");
        int i = bt.d().g_();
        b = false;
        cc cc1 = new cc(i);
        for(int j = 0; j < i; j++)
        {
            aw aw1 = (aw)bt.d().a(j);
            al al1;
            if((al1 = a(aw1.e, aw1.f)) == null)
            {
                al al2 = a(0, aw1.f);
                al1 = new al(this, aw1.e, aw1.f, aw1.c, aw1.t, null, al2 == null ? null : al2.e);
            }
            al1.d = false;
            al1.c = aw1.t;
            cc1.e(al1);
        }

        a.b();
        a = cc1;
    }

    private al a(int i, int j)
    {
        int k = 0;
        for(int l = a.a; k < l; k++)
        {
            al al1 = (al)a.a(k);
            if(i == 0)
            {
                if(j == al1.b && al1.e != null)
                    return al1;
                continue;
            }
            if(j == 0)
            {
                if(i == al1.a)
                    return al1;
                continue;
            }
            if(i == al1.a && j == al1.b)
                return al1;
        }

        return null;
    }

    public final void a(int i, String s)
    {
        if(i == -1)
            b = true;
        if(i == 0 || a == null || a.a == 0 || s == null || s.length() == 0)
            return;
        al al1;
        if((al1 = a(i, 0)) != null)
        {
            al1.d = true;
            al1.c = true;
            bm.a();
        }
    }

    public final boolean a(int i)
    {
        if(i == -1)
            return b;
        if(a == null || a.a == 0)
            return false;
        if(i == 0)
        {
            boolean flag = false;
            int j = 0;
            for(int k = a.a; j < k; j++)
            {
                al al2 = (al)a.a(j);
                aw aw1;
                if((aw1 = bt.d().b(al2.a)) != null)
                    aw1.t = al2.c;
                if(al2.d)
                    flag = true;
            }

            return flag;
        }
        al al1;
        if((al1 = a(i, 0)) == null)
            return false;
        else
            return al1.d;
    }

}